package com.whfc.fvs.config;

import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySources;
import com.whfc.common.file.FilePathConfig;
import com.whfc.common.third.uni.UniApi;
import com.whfc.common.third.uni.UniProperties;
import com.whfc.common.third.uni.impl.UniApiImpl;
import com.whfc.common.vs.aliyun.VsProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author : qzexing
 * @version : 1.0
 * @date : 2020-09-22 15:26
 */
@Configuration
@NacosPropertySources(value = {
        @NacosPropertySource(dataId = "com.whfc.fvs.properties", autoRefreshed = true),
        @NacosPropertySource(dataId = "com.whfc.common.properties", autoRefreshed = true)
})
public class FvsConfig {

    @Value("${spring.profiles.active}")
    private String profile;

    @Bean("msFilePathConfig")
    public FilePathConfig msFilePathConfig() {
        FilePathConfig config = new FilePathConfig("ms", profile);
        return config;
    }

    /**
     * 阿里云视频监控参数
     *
     * @return
     */
    @Bean("aliyunVsProperties")
    @ConfigurationProperties("aliyun.vs")
    public VsProperties aliyunVsProperties() {
        return new VsProperties();
    }

    @Bean
    @ConfigurationProperties(prefix = "third.uni")
    public UniProperties uniProperties() {
        return new UniProperties();
    }

    @Bean
    public UniApi uniApi(UniProperties uniProperties) {
        return new UniApiImpl(uniProperties);
    }
}
